package com.ruoyi.back.controller.v3

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.v3.dto.UserRecordSearchDto
import com.ruoyi.back.domain.v3.vo.UserRecordListVo
import com.ruoyi.back.domain.v3.vo.UserRecordNum
import com.ruoyi.back.service.v3.MyRecordService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/system/userRecord")
@Api(tags = ["作品管理"])
class UserRecordController {

    @Autowired
    private lateinit var myRecordService: MyRecordService


    @ApiOperation("用户作品列表")
    @GetMapping("userRecordList")
    fun userRecordList(userRecordSearchDto: UserRecordSearchDto): PageData<UserRecordListVo> =
        myRecordService.userRecordList(userRecordSearchDto).pageInfo()

    @ApiOperation("管理员添加作品")
    @PostMapping("adminAddUserRecord")
    fun adminAddUserRecord(@RequestBody adminRecord: MyRecordService.AdminRecord): Data<Boolean> =
        myRecordService.adminAddUserRecord(adminRecord)

    @ApiOperation("移除作品")
    @GetMapping("removeUserRecord")
    fun removeUserRecord(ids: String): Data<Boolean> = myRecordService.removeUserRecord(ids)

    @ApiOperation("用户作品统计信息")
    @GetMapping("userRecordNum")
    fun userRecordNum(): Data<UserRecordNum> = myRecordService.userRecordNum()

    @ApiOperation("推荐或者取消推荐到banner")
    @PostMapping("recommendBanner")
    fun recommendBanner(recordId: Long): Data<Boolean> = myRecordService.recommendBanner(recordId)

    @ApiOperation("上架或者下架")
    @GetMapping("upRecord")
    fun upRecord(recordId: Long): Data<Boolean> = myRecordService.upRecord(recordId)

    @ApiOperation("置顶或者取消置顶")
    @GetMapping("topRecord")
    fun topRecord(recordId: Long): Data<Boolean> = myRecordService.topRecord(recordId)
}